package com.example.demo.service.impl;

import com.example.demo.entity.Forward;
import com.example.demo.mapper.ForwardMapper;
import com.example.demo.service.IForwardService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * <p>
 * 转发文章表 服务实现类
 * </p>
 *
 * @author Mr.Xiayh
 * @since 2024-06-05
 */
@Service
public class ForwardServiceImpl extends ServiceImpl<ForwardMapper, Forward> implements IForwardService {
    @Autowired
    private ForwardMapper forwardMapper;

    @Override
    public int countForwardByUserAndArticle(Integer articleId) {
        if (articleId != null) {
            return forwardMapper.countForwardByUserAndArticle(articleId);
        }
        return 0;
    }

    @Override
    public boolean addForward(Forward forward) {
        if(forwardMapper.addForward(forward) == 1){
            return true;
        }
        return false;
    }

    @Override
    public String getForwardContent(Integer articleId) {
        return forwardMapper.getForwardByArticleId(articleId);
    }

    @Override
    public Integer getForwardUserIdByArticleId(Integer articleId) {
        return forwardMapper.getForwardUserIdByArticleId(articleId);
    }

    @Override
    public List<Integer> getForwardArticleIdByUserId(Integer userId) {
        return forwardMapper.getForwardArticleIdByUserId(userId);
    }
}
